package com.slofzx.nuoda.evaluation.project.enums;

import com.slofzx.nuoda.common.EnumConfig;
import com.slofzx.nuoda.common.config.Type;

/**
 * 油气品种枚举
 * @author sunhaifeng
 */
@EnumConfig(
    id = "oil-product-property",
    name = "油品质"
)
public enum OilProductPropertyEnum implements Type {
    LIGHT_OIL("light_oil", "轻质油",1),
    MEDIUM_OIL_1("medium_oil_1", "中质油I",2),
    MEDIUM_OIL_2("medium_oil_2", "中质油II",3),
    HEAVY_OIL("heavy_oil", "重质油",4),
    THICK_OIL("thick_oil", "稠油",5),
    SUPER_THICK_OIL("super_thick_oil", "特稠油",6),
    SPECIAL_OIL("special_oil", "特种油",7),

    ;

    /**
     * 标识
     */
    private String id;
    /**
     * 名称
     */
    private String name;
    /**
     * 排序值
     */
    private double sort;

    OilProductPropertyEnum(String id, String name, double sort) {
        this.id = id;
        this.name = name;
        this.sort = sort;
    }

    @Override
    public String getId() {
        return this.id;
    }

    @Override
    public String getName() {
        return this.name;
    }

    /**
     * 根据标识获取枚举值
     * @param id
     * @return
     */
    public static OilProductPropertyEnum getEnum(String id) {
        for(OilProductPropertyEnum item:values()) {
            if (item.getId().equals(id)) {
                return item;
            }
        }
        return null;
    }

    public static OilProductPropertyEnum getEnumByName(String name) {
        for(OilProductPropertyEnum item:values()) {
            if (item.getName().equals(name)) {
                return item;
            }
        }
        return null;
    }

}
